<?php
/**
 * Created by PhpStorm.
 * UsersF: Mloong
 * Date: 2018/12/18
 * Time: 14:28
 */

namespace app\api\controller\v1;

use app\api\controller\BaseController;
use app\api\service\TongdunService;
use app\api\validate\TongdunParam;
use app\lib\exception\ParameterException;
use Driver\Cache\Redis;
use think\facade\Request;

class Tongdun extends BaseController
{
    protected $middleware = [
        'checkTongdun' => ['only' => ['test']],
        'log' => ['only' => ['test']]
    ];

    public function tongdun()
    {
        $post = Request::post();
        $validate = new TongdunParam();
        if($validate->check($post) == false){
            throw new ParameterException([
               'msg' => $validate->getError()
            ]);
        }
        $tongdun = new TongdunService($post);
        $result = $tongdun->tongdun();
        return json($result);
    }
}